//
//  BNRItemCoontainer.m
//  Quiz
//
//  Created by YaoJacob on 15/11/1.
//  Copyright © 2015年 Roger. All rights reserved.
//

#import "BNRItemContainer.h"

@implementation BNRItemContainer

-(instancetype)init
{
    self = [super init];

    self.itemName = @"";
    self.valueInDollars = 9;
    //dateCreated = [[NSDate alloc]init];
    self.serialNumber = @"as";
    _subItems = [NSMutableArray arrayWithCapacity:3];  //如何初始化？
    return self;
}

-(int)addBNRItem:(BNRItem*)subItem
{
    [_subItems addObject:subItem];
    return (int)_subItems.count;
}

-(NSString*)description
{
    NSString * ret = [[NSString alloc]init];
    int totalMoney = 0;
    for (id item in _subItems) {
        BNRItem * p = item;
        
        totalMoney += p.valueInDollars;
        ret = [NSString stringWithFormat:@"%@, %@", ret, p];
    }
    
    ret = [NSString stringWithFormat:@"%@, total: %d", ret, totalMoney];
    return ret;
    
}
@end
